package com.cmo.common.controller.doctor;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.cmo.common.model.Doctor;
import com.cmo.common.model.Pager;
import com.cmo.common.utils.ToolString;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Record;

public class DoctorController extends Controller {

	Doctor service=new Doctor();
	Pager pager=new Pager();
	public void doctor_room_door(){
		Map<String, Object> map=new HashMap<String, Object>();
		String ip=getPara("ip");
		if(ToolString.isBlank(ip)){
			map.put("return_code", "fail");
			map.put("return_msg", "请传入ip");
			renderJson(map);
			return;
		}
		Record record= service.queryByip(ip);
		if(null==record){
			map.put("return_code", "fail");
			map.put("return_msg", "还未有医生登陆诊室");
			renderJson(map);
			return;
		}else{
			map.put("return_code", "success");
			map.put("return_msg", "信息查询成功");
			map.put("doctorinfo", record);
			renderJson(map);
		}
		renderJson(map);
	}
	public void list_doctor(){
		Map<String, Object> map=new HashMap<String, Object>();
		//String name=getPara("name");
		List<Record> list= service.list_doctor();
		if(list.isEmpty()){
			map.put("return_code", "fail");
			map.put("return_msg", "查询失败");
			renderJson(map);
			return;
		}else{
			map.put("return_code", "success");
			map.put("return_msg", "查询医生成功");
			map.put("count", list.size());
			map.put("list", list);
			renderJson(map);
		}
	}
}
